Repository navigation
Compile lifted user-defined AndAlso and OrElse operators - #597
Merged
dadhi merged 2 commits intoNov 9, 2026
Merged
Conversation
dadhi
requested changes
Nov 8, 2026
jogibear9988
force-pushed
the
fix/lifted-user-logical-operators
branch
from
November 8, 2026 22:08
e40fdeb to
1f0eb9e
Compare
Add a nullable custom-operator path using existing locals, nullable accessors and method emission. Preserve null and decisive-left short circuits, selected bitwise methods, ignored effects and right-side finally cleanup. Keep ordinary Boolean and non-lifted operator paths in place.
Move non-lifted custom logical emission out of the main switch and share operand storage, truth testing, ordered right evaluation, method calls and branch merging. Keep nullable checks and labels conditional on lifting, preserving existing lookup and operand contexts. Add standard and Light regression coverage for reference and struct operators, explicit methods, ignored effects and exception regions.
jogibear9988
force-pushed
the
fix/lifted-user-logical-operators
branch
from
November 9, 2026 05:21
015c10a to
394f8e8
Compare
Owner
|
thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compile valid AndAlso/OrElse expressions over nullable structs with user-defined logical operators, which currently fail strict FEC compilation.
Use one
TryEmitUserDefinedLogicalOperatorhelper for both lifted and non-lifted custom operators. Share left operand storage, op_False/op_True testing, right operand evaluation on an empty stack, the selected bitwise method call, short-circuit branches, and result merging. Keep nullable checks, unwrapping, wrapping, and null-result labels conditional on lifting. Existing method lookup and operand contexts are preserved for each path; ordinary Boolean emission remains separate.Strict Standard/LightExpression tests cover:
Validation
Current master base:
76f2b28f9363d3364be75dc9830c7e303aea8b3a. Release solution build: zero warnings/errors. Both APIs have strict regression coverage with fallback disabled.Shared-helper measurements
Compare separate emitters (
1bac8a3b) with the shared helper (394f8e85), both built on the master base above. Both configurations support the measured lifted expressions; these are direct before/after measurements of helper unification. Master itself does not successfully compile those lifted trees.Windows ARM64, .NET 8.0.28 and 10.0.9, Release, tiering disabled. Prebuilt trees, Light conversion outside timing, isolated load contexts, one CPU, nine alternating samples per phase, and two fresh process rounds in opposite load order with approximately 100 ms pair calibration. Compilation and invocation are measured separately. Timings combine the 18 samples; allocation counts use thread allocation counters.
Every measured case retains identical emitted IL and unchanged compilation allocations. All measured invocations allocate zero. The measurements cover non-lifted struct/reference operators, lifted value/null paths, AndAlso/OrElse and a Boolean control. CPU timings vary between rounds; slower observations are retained below, and no exact timing-neutrality or speedup claim is made.
All measurements: separate emitters → shared helper
boolean_andcustom_andlifted_and_valueslifted_and_nullcustom_orreference_andlifted_and_right_nulllifted_or_valuesboolean_andcustom_andlifted_and_valueslifted_and_nullcustom_orreference_andlifted_and_right_nulllifted_or_valuesboolean_andcustom_andlifted_and_valueslifted_and_nullcustom_orreference_andlifted_and_right_nulllifted_or_valuesboolean_andcustom_andlifted_and_valueslifted_and_nullcustom_orreference_andlifted_and_right_nulllifted_or_values